<template>
  <div>
    <div id="main"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
// type EChartsOption = echarts.EChartsOption;
export default {
  mounted() {
    this.A();
    this.http()
  },
  methods: {
    http() {
      let url = "https://www.miaodaoiot.com/admin.php/BasicSet/getRoleList";
      axios.post(url)
      .then(res => {
        console.log(res)
      })
      .catch(err => {
        console.error(err); 
      })
    },
    A() {
      var chartDom = document.getElementById("main");
      var myChart = echarts.init(chartDom);
      // var option:EChartsOption;
      var option = {
        tooltip: {
          trigger: "axis",
          axisPointer: { type: "none" },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            data: ["1", "2", "3", "4", "5", "6", "7", "8"],
            axisTick: {
              alignWithLabel: true,
            },
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "Direct",
            type: "bar",
            barWidth: "60%",
            data: [10, 52, 200, 334, 390, 330, 220],
          },
        ],
      };
      option && myChart.setOption(option);
    },
  },
  setup() {
    return {};
  },
};
</script>

<style lang="scss" scoped>
#main {
  height: 400px;
}
</style>